package com.xiaotu.StudyProxy;

/**
 * @Author xiaotu
 * @Description //TODO
 * @Date 2022/3/25 11:43
 * @ClassName StaticProxy
 * @Version 1.0
 * 静态代理
 *真实对象和代理对象都要实现同一个接口
 * 代理对象要代理真实角色
 **/
public class StaticProxy {
    public static void main(String[] args) {
        Marry you = new you();
        WeddingCompany weddingCompany = new WeddingCompany(you);
        weddingCompany.HappyMarry();
        /**
         * Runnable runnable = new Runnable();
         * new Thread(runable).start();
         */
    }
}
interface Marry{
    void HappyMarry();
}
class you implements Marry{
    @Override
    public void HappyMarry() {
        System.out.println("关于结婚他很开心");
    }
}
class WeddingCompany implements Marry{
    private Marry target;
    public WeddingCompany(Marry marry){
        this.target = marry;
    }
    @Override
    public void HappyMarry() {
        before();
        this.target.HappyMarry();
        after();
    }
    private void before() {
        System.out.println("准备工作");
    }
    private void after(){
        System.out.println("付尾款");
    }
}
